package com.example.myapplication.db.domain;

import com.example.myapplication.Sign.AESCrypt;

import java.io.Serializable;
import java.sql.ResultSet;

public class UserBean implements Serializable {
    private int id;
    private String phone;
    private String password;
    private String alipayCode;

    public UserBean(String phone, String password, String alipayCode) {
        this.phone = phone;
        this.password = password;
        this.alipayCode = alipayCode;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getAlipayCode() {
        return alipayCode;
    }

    public void setAlipayCode(String alipayCode) {
        this.alipayCode = alipayCode;
    }

    public static UserBean toObject(ResultSet resultSet) {
        try {
            UserBean bean = new UserBean(
                    resultSet.getString("phone"),
                    resultSet.getString("password"),
                    resultSet.getString("alipayCode")
            );
            bean.setId(resultSet.getInt("id"));
            return bean;
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}
